package com.zlsy.learning.leetcode.arraycorrelation.array1486;

/**
 * @author zhouliang
 * @date 2020/7/8 21:32
 */
public class XorOperation {

    private static int xorOperation(int n, int start) {
        int[] num = new int[n];
        int a = 0;
        for (int i = 0; i < num.length; i++) {
            num[i] = start + 2 * i;
            if (i == 0) {
                a = num[i];
            } else {
                a = a ^ num[i];
            }
        }
        return a;
    }

    public static void main(String[] args) {
        System.out.println(xorOperation(5, 0));
        System.out.println(xorOperation(4, 3));
        System.out.println(xorOperation(1, 7));
    }
}
